home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / dbase / do1beta.zip / FACTOR.DO < prev    next >
Text File  |  1991-07-18  |  284b  |  18 lines

  1. /*
  2.     define a recursive factorial method for the "Long" class
  3. */
  4. method Long::factorial(self)
  5. {
  6.     if(self <= 1L) return(self);
  7.     else return(self*factorial(self-1L));
  8. }
  9.  
  10. /* 
  11.     calculate some factorials
  12. */
  13. i = 0;
  14. while(i < 10) {
  15.     ? i," ",factorial(asLong(i));
  16.     i = i+1;
  17. }
  18.